import React, { useState, useMemo, useEffect, useCallback, useRef } from 'react'

export default function About8() {
    const [count, setCount] = useState(10)
    const [num, setNum] = useState(200)
    const ref = useRef()

    function addCount() {
        // console.log('count修改了')
        setCount(count + 1)
    }

    const getCount = useMemo(() => {
        console.log('count修改了')
        return count * 2
    }, [count])

    // useCallback(() => {
    //     return () => {

    //     }
    // }, [])

    useEffect(() => {
        console.log(ref.current)
    })

    

    return (
        <div>
            <h1 ref={ref}>
                我是标题
            </h1>
            About8 -- {count}
            <h3>
                {getCount}
            </h3>
            <button onClick={addCount}>count+1</button>

            <h3>
                {num}
            </h3>
            <button onClick={() => {
                setNum(num + 1)
            }}>num+1</button>
        </div>
    )
}
